<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        html,body,div{
            margin: 0;
            padding: 0;
        }

        #fdj img{
            width: 500px;
            height: 500px;
        }
        #fdjbox{
            position: absolute;
            left: 500px;
            top: 0px;
            display: none;
            width: 500px;
            height: 500px;
            overflow: hidden;
        }
        #fdj .mengban{
            width: 200px;
            height: 200px;
            position: absolute;
            left: 0px;
            top: 0px;
            background-color: yellow;
            opacity: 0.4;
            display: none;
        }
        #fdjbox img {
            width: 1250px;
            height: 1250px;
            position: relative;
        }
    </style>
</head>
<body>
  <!--放大镜-->
 <div id="fdj">
   <img id="adimg" src="66066a85cec2e.webp" alt="" srcset="">
  <div id="mengban" class="mengban"></div>
  <div id="fdjbox" class="fdjbox">
    <img id="fdjimg" src="66066a85cec2e.webp" alt="" srcset="">
  </div>
 </div>
</body>
</html>
<script>
    var adimg = document.getElementById("adimg");
    var mengban =document.getElementById("mengban");
    var fdjbox =document.getElementById("fdjbox");
    var fdjimg = document.getElementById("fdjimg");
    window.onload = function () {
        adimg.onmousemove = function (event){
            mengban.style.display ="block"
            fdjbox.style.display = "block"
            var mengbanleft = event.clientX -100;
            var mengbantop = event.clientY -100;
            mengbanleft = mengbanleft > 300 ? 300: mengbanleft
            mengbantop = mengbantop > 300 ? 300: mengbantop
            mengbanleft = mengbanleft < 0 ? 0 : mengbanleft
            mengbantop = mengbantop < 0 ? 0 :mengbantop
            mengban.style.left = mengbanleft+'px'
            mengban.style.top = mengbantop+'px'
        }
        mengban.onmousemove = function (event){
            var mengbanleft = event.clientX -100;
            var mengbantop = event.clientY -100;
            mengbanleft = mengbanleft > 300 ? 300 : mengbanleft
            mengbantop = mengbantop > 300 ? 300 : mengbantop
            mengbanleft = mengbanleft < 0 ? 0 : mengbanleft
            mengbantop = mengbantop < 0 ? 0 :mengbantop
            mengban.style.left = mengbanleft+'px'
            mengban.style.top = mengbantop+'px'
            fdjimg.style.left =-1*parseInt( mengbanleft *2.5) + "px"
            fdjimg.style.top =-1*parseInt( mengbantop *2.5) + "px"
        }
        adimg.onmouseout = function (){
            mengban.style.display="none"
            fdjbox.style.display = "none"
        }
        mengban.onmouseout = function (){
            mengban.style.display = "none"
            fdjbox.style.display = "none"
        }
    }
</script>